package com.lcj.crawler;

import com.geccocrawler.gecco.pipeline.Pipeline;
import com.lcj.service.CompanyRecruitInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SaveZptContactPipeline implements Pipeline<ZptContactPage> {

    @Resource(name="companyRecruitInfoServiceImpl")
    private CompanyRecruitInfoService companyRecruitInfoService;
    @Override
    public void process(ZptContactPage zptContactPage) {
        String recruitId = zptContactPage.getRecruitId();
        String recruitUrl = "https://www.zptong.com/jobs/jobs-show-"+recruitId+"-.htm";
        String contactPerson = "";
        String phone = "";
        String email = "";
        String address = "";
        if(zptContactPage.getEmail()!=null){
            contactPerson = zptContactPage.getContactPerson();
//            String telPhone = zptContactPage.getTelPhone();
            phone = "手机号码:"+zptContactPage.getTelPhone()+"固定电话"+zptContactPage.getPhone();
            email = zptContactPage.getEmail();
            address = zptContactPage.getAddress();
        }else{
            contactPerson = zptContactPage.getContactPerson();
            phone = zptContactPage.getTelPhone();
            email = zptContactPage.getPhone();
            address = zptContactPage.getAddress();
        }
//        System.out.println("=================联系方式："+contactPerson+phone+email+address);
        companyRecruitInfoService.update(recruitUrl,contactPerson,phone,email,address);
    }
}
